<?php

echo "Student list:<br>";
include('Student.php');
include('Course.php');
$students = array();

$math = new Course("MATH101", "math", 4);
$English = new Course("ENG102", "English", 3);
$physics = new Course("PHY103", "physics", 4);
$chemistry = new Course("CHEM201", "chemistry", 3);
$programming = new Course("CS301", "programming", 5);

$first = new Student("Doe", "John","Junior"); 
$first->add_email('home', 'john@doe.com'); 
$first->add_email('work', 'jdoe@mcdonalds.com'); 
$mathCourse = new Course("MATH101", "高等数学", 4);
$engCourse = new Course("ENG102", "英语写作", 3);
$phyCourse = new Course("PHY103", "大学物理", 4);
$first->add_grade($math,65); 
$first->add_grade($English,75); 
$first->add_grade($programming,55); 
$students['j123'] = $first; 

$second = new Student("Einstein", "Albert", "Freshman"); 
$second->add_email('home', 'albert@braniacs.com'); 
$second->add_email('work1', 'a_einstein@bcit.ca'); 
$second->add_email('work2', 'albert@physics.mit.edu'); 
$second->add_grade($math,95); 
$second->add_grade($physics,80); 
$second->add_grade($programming,50); 
$students['a456'] = $second; 

$third = new Student("Cheng", "Zizhuo", "Junior");
$third->add_email('home', '2982585308@qq.com');
$third->add_email('work','2982585308@qq.com');
$third->add_grade($math,99);
$third->add_grade($programming,99);
$third->add_grade($chemistry,99);
$students['c789'] = $third;

$fourth = new Student("Li", "kay", "Senior");
$fourth->add_email('home', 'kay@microsoft.com');
$fourth->add_email('work', 'kay@microsoft.com');
$fourth->add_grade($programming,98);
$fourth->add_grade($physics,95);
$fourth->add_grade($English,95);
$students['b012'] = $fourth;

ksort($students); // one of the many sort functions 

foreach ($students as $student)
    echo $student->toString();